﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessTier;

public partial class ChangePassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((Session["username"] == null) || (Session["username"].ToString().CompareTo("") == 0))
        {
            Response.Redirect("Login.aspx?Redirect=Account"); 
        }
        else
        {
            String username = Session["username"].ToString();
        }
    }

    protected void Reset_Button(object sender, EventArgs e)
    {
        Result.Visible = false;

        String username = Session["username"].ToString();
        String password = Password.Text;

        var Client = new BusinessTier.DataManipulation();
        bool success = (bool)Client.ChangePassword(username, password);
        

        String result;
        if (success)
        {
             result = "Password successfully changed!";
        }
        else
        {
            result = "An error occurred when changing your password!";
        }

        Result.Text = result;
        Console.Write(result);
        Result.Visible = true;
    }

}